package com.guigu.financial.controller;

import com.guigu.financial.pojo.IntegralGrade;
import com.guigu.financial.service.IntegralGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/integralGrade")
public class IntegralGradeController {
    @Autowired
    IntegralGradeService integralGradeService;

    @PostMapping("")
    public void save(@RequestBody IntegralGrade integralGrade){
        integralGradeService.insertSelective(integralGrade);
    }

    @GetMapping("")
    public List<IntegralGrade> findAll(){
        return integralGradeService.findAll();
    }

    @GetMapping("/{id}")
    public IntegralGrade findAll(@PathVariable("id") Long id){
        return integralGradeService.selectByPrimaryKey(id);
    }

    @GetMapping("delete")
    public void deleteById(Long id){
        IntegralGrade integralGrade = new IntegralGrade();
        integralGrade.setId(id);
        integralGrade.setIsDeleted(true);
        integralGradeService.updateByPrimaryKeySelective(integralGrade);
    }

    @PutMapping("")
    public void updat(@RequestBody IntegralGrade integralGrade){
        integralGradeService.updateByPrimaryKeySelective(integralGrade);

    }
}
